import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: https://www.nowcoder.com/questionTerminal/8869d99cf1264e60a6d9eff4295e5bab
 * User: 86187
 * Date: 2022-10-10
 * Time: 21:50
 */
public class Test2 {
    /**
     *  自己的写法.
     */
    public static StringBuilder sb = new StringBuilder();
    private static void func(String str, int count) {
        if(count < 0) return;

        int k = 0;
        int i = 0;
        for(; i < str.length() && k < count; ++i) {
            if(str.charAt(i) == ' ') {
                ++k;
            }
        }
        String s = str.substring(i);
        sb.append(s);
        if(count != 0) {
            sb.append(" ");
        }
        int j = (i - 1) < 0 ? i : i - 1;
        func(str.substring(0,j),count-1);
    }

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        String str = in.nextLine();

        int count = 0;
        for(int i = 0; i < str.length(); ++i) {
            if(str.charAt(i) == ' ') count++;
        }

        func(str,count);
        System.out.println(sb.toString());
    }

    /**
     *  答案
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        char[] ch = str.toCharArray();
        int length = ch.length;

        // 1. 整体逆置字符串.
        reserve(ch,0,length-1);

        // 2. 逆置每个单词
        int i = 0;
        while(i < length) {
            int j = i;
            while (j < length && ch[j] != ' ')
                ++j;
            if(j < length) {
                reserve(ch,i,j-1);
                i = j + 1;
            } else {
                reserve(ch,i,j-1);
                i = j;
            }
        }
        String s = new String(ch);
        System.out.println(s);
    }
    private static void reserve(char[] ch, int start, int end) {
        while(start < end) {
            char tmp = ch[start];
            ch[start] = ch[end];
            ch[end] = tmp;
            start++;
            end--;
        }
    }
}
